<?php
session_start();
$nombre =$_POST['nombre'];
$mailUser = $_POST['email'];
$Pass = $_POST['pass'];
$date = date("Y-m-d");

      $link = mysql_connect("localhost","root","");
      mysql_select_db("personalizatuweb", $link);
	  
	  
	  $consultaSQL = "INSERT INTO personalizatuweb.usuarios (NOMBREUSUARIO,PASSWORD,EMAIL,FECHAINCORPORACION,TIPOUSUARIO,FECHATOPEPRIVILEGIO) VALUES ('".$nombre."','".$Pass."','".$mailUser."','".$date."','0','00-00-00')";
	  
	  $res = mysql_query($consultaSQL, $link) or die(mysql_error());

	 $result = mysql_query("SELECT * FROM usuarios where EMAIL='".$mailUser."' and PASSWORD='".$Pass."'", $link) or
  die("Problemas en el la consulta SELECT:".mysql_error());
  
      $CantResult = mysql_num_rows($result);
	  
	 if($CantResult > 0){
		 while( $row = mysql_fetch_array($result)){
	   	 $_SESSION['CODIGO_USUARIO'] = $row['ID_USUARIO'];
		 
		 mysql_close($link);
		 header ("Location: User/index.php");}
	  }
	  else{
				
		echo"<script language='JavaScript'> alert('USUARIO NO VALIDO');</script>";
		mysql_close($link);
		header ("Location: index.html");				
		}

	
?>